package com.michir.projects.jms.mocks;

import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Session;

import org.mockito.Mockito;

/**
 * {@link Connection} Mocker: uses {@link Mockito}.
 * 
 * @author michir
 */
public class ConnectionMocker {

	/**
	 * use {@link #mock(Session, Boolean, Integer)}
	 */
	private ConnectionMocker() {}

	/**
	 * {@link Connection} factory method.
	 * @param session
	 * @param transacted 
	 * @param acknowledgeMode 
	 * @return
	 * @throws JMSException 
	 */
	public static Connection mock(Session session, Boolean transacted, Integer acknowledgeMode) throws JMSException {
		Connection connection = Mockito.mock(Connection.class);
		Mockito.when(connection.createSession(transacted, acknowledgeMode)).thenReturn(session);
		return connection;
	}
}
